//
//  Rank_ReceiveRecordListController.m
//  YLProject
//
//  Created by 张伯林 on 2018/2/6.
//  Copyright © 2018年 WY. All rights reserved.
//

#import "Rank_ReceiveRecordListController.h"
#import "Rank_ReceiveConListHeaderView.h"
#import "Rank_ReceiveGiftListHeaderCell.h"
#import "Rank_ReceiveGiftLatelyListCell.h"
#import "Rank_PeopleInfoController.h"
@interface Rank_ReceiveRecordListController ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)Rank_ReceiveConListHeaderView *conHeaderView;
@property(nonatomic,strong)UITableView *tableView;
@property(nonatomic,strong)NSMutableArray *dataSource;
@end

@implementation Rank_ReceiveRecordListController

- (void)viewDidLoad {
    [super viewDidLoad];
    AdjustsScrollViewInsetNever(self, self.tableView)
    self.navigationItem.title = @"女王皇冠👑";
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.conHeaderView];
    [self.view addSubview:self.tableView];
}
#pragma mark ---tableView代理方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 1;
    }
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 60;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if(section == 1){
        return 44;
    }
    return 0.01;
}
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (section == 1) {
        UIView *back = [[UIView alloc]init];
        back.backgroundColor = [UIColor whiteColor];
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, Screen_Width - 30 ,44 )];
        label.font = YLFont(13);
        label.textColor = [UIColor grayColor];
        label.text = @"最近获赠记录";
        [back addSubview:label];
        return back;
    }
    return nil;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        Rank_ReceiveGiftListHeaderCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([Rank_ReceiveGiftListHeaderCell class])];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;
    }
    Rank_ReceiveGiftLatelyListCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([Rank_ReceiveGiftLatelyListCell class])];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    Rank_PeopleInfoController *rank_info = [[Rank_PeopleInfoController alloc]init];
    [self.navigationController pushViewController:rank_info animated:YES];
}
-(UITableView *)tableView{
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 36, Screen_Width, Screen_Height - (STATUS_BAR_HEIGHT + 44) - 36) style:UITableViewStyleGrouped];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsHorizontalScrollIndicator = NO;
        _tableView.showsVerticalScrollIndicator = NO;
        [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:NSStringFromClass([UITableViewCell class])];
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass(Rank_ReceiveGiftListHeaderCell.class) bundle:nil] forCellReuseIdentifier:NSStringFromClass(Rank_ReceiveGiftListHeaderCell.class)];
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass(Rank_ReceiveGiftLatelyListCell.class) bundle:nil] forCellReuseIdentifier:NSStringFromClass(Rank_ReceiveGiftLatelyListCell.class)];
        _tableView.tableFooterView = [UIView new];
        _tableView.backgroundColor = kHEXCOLOR(@"f4f5f7");
    }
    return _tableView;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(Rank_ReceiveConListHeaderView *)conHeaderView{
    if (!_conHeaderView) {
        _conHeaderView = [Rank_ReceiveConListHeaderView conHeaderView];
        _conHeaderView.center = CGPointMake(Screen_Width / 2, YL_STATUS_HEIGHT + _conHeaderView.height / 2);
    }
    return _conHeaderView;
}
-(NSMutableArray *)dataSource{
    if (!_dataSource) {
        _dataSource = [NSMutableArray array];
    }
    return _dataSource;
}
@end
